function createUserList() {
    return {
        status: 0,
        data: [
            {
                token: "Admin Token",
                _id: "641280fdc5ff3cb994002003",
                username: "test1",
                name: "测试用户1",
                password: "1234",
                phone: "13112345678",
                role_id: "640ec59a9f6e3402f8edd4ec",
                create_time: 1678934269969,
                __v: 0,
                role: {
                    _id: "640ec59a9f6e3402f8edd4ec",
                    name: "管理员",
                    menus: [
                        "/home",
                        "/user",
                        "/role",
                        "/school",
                        "/majors",
                        "/student",
                        "/class",
                    ],
                    create_time: 1678689690752,
                    __v: 0,
                    auth_time: 1678952409061,
                    auth_name: "test1",
                },
            },
            {
                token: "System Token",
                _id: "64098cc6984047a6c854b303",
                username: "admin",
                password: "admin",
                create_time: 1678347462193,
                __v: 0,
                role: {
                    menus: [],
                },
            },
        ]
    }
}
export default [
    //登录接口
    {
        url: "/mock/login",
        method: 'post',
        response: ({ body }) => {
            // 获取到请求时携带的用户名和密码
            const { username, password } = body
            //调用上面的方法创建用户数组
            const userArr = createUserList().data
            //在数组中查询如何当前元素的用户名和密码与前端请求时提交的一致，则代表登录成功
            const checkUser = userArr.find((item) => {
                return item.username === username && item.password === password
            })
            //如果checkuser是空的，代表用户名或密码错误
            if (!checkUser) {
                return { status: 1, msg: "用户名或密码错误" }
            }
            //获取成功
            const { token } = checkUser
            return { status: 0, data: { token } }
        },
    },
    // 获取用户信息接口
    {
        url: "/mock/user/info",
        method: 'get',
        response: (request) => {
            //先获取到请求头中携带的token
            const token = request.headers.token;
            //调用上面的方法获取用户数组
            const userArr = createUserList().data
            const checkUser = userArr.find((item) => {
                return item.token === token
            })
            if (!checkUser) {
                return { status: 1, data: { message: '获取用户信息失败' } }
            }
            return { status: 0, data: { ...checkUser } }
        }
    }
]